package com.csy.admin.web;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.csy.admin.entity.ResourceClass;
import com.csy.admin.service.ResourceClassService;
import com.csy.admin.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 类名:资源分类控制类
 * Created by CSY on 2018/9/17.
 */
@RestController
@RequestMapping("/resourceClass")
public class ResourceClassController {

    @Autowired
    private ResourceClassService resourceClassService;

    @RequestMapping(value = "/list/{typeId}",method = RequestMethod.GET)
    public Result list(@PathVariable("typeId") Integer typeId){
        List<ResourceClass> classList = resourceClassService.list(
                new QueryWrapper<ResourceClass>().eq("resource_type_id",typeId));
        ResourceClass resourceClass = new ResourceClass();
        resourceClass.setClassId(-1);
        resourceClass.setClassName("全部");
        resourceClass.setFlagInvalid(0);
        classList.add(resourceClass);
        return Result.ok().put("classList",classList);
    }
}
